package com.ocom.xcxapi.service.impl;


import com.ocom.common.constant.MapKey;
import com.ocom.common.resp.Result;
import com.ocom.xcxapi.client.AccessClientService;
import com.ocom.xcxapi.client.HumanClientService;
import com.ocom.xcxapi.service.FangKeService;
import com.ocom.xcxapi.vo.fangke.GetFiledListVo;
import com.ocom.xcxapi.vo.fangke.UpdateVisitorRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;


import java.util.HashMap;
import java.util.Map;

@Service
public class FangKeServiceImpl implements FangKeService {

    @Autowired
    private HumanClientService humanClientService;


    @Autowired
    private AccessClientService accessClientService;
    /**
     * 2.11.访客申请列表（fangke/getFiledList）
     * */
    @Override
    public Result FangkeGetFiledList(GetFiledListVo getFiledListVo) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(),getFiledListVo.getComId());
        map.put(mapKey.getKey_applyId(),getFiledListVo.getApplyId());
        map.put(mapKey.getKey_approverId(),getFiledListVo.getApproveId());
        map.put(mapKey.getKey_status(),getFiledListVo.getStatus());
        map.put(mapKey.getKey_page(),getFiledListVo.getPage());
        map.put(mapKey.getKey_size(),getFiledListVo.getSize());
        return  humanClientService.GetVisitorRecord(map);
    }

    /**
     * 2.12.添加访客申请（fangke/addFiled）
     * */
    @Override
    public Result FangkeAddFiled(Map<String,Object> map) {
        return  humanClientService.AddVisitorRecord(map);
    }

    /**
     * 2.13.补充访客人员（fangke/addGuest）
     * */
    @Override
    public Result FangkeAddGuest(Map<String,Object> map) {

        return humanClientService.AddVisitorInfo(map);
    }


    /**
     * 2.14.删除访客申请（fangke/delFiled）
     * */
    @Override
    public Result FangkeDelFiled(Map<String,Object> map) {

        return humanClientService.DeleteVisitorRecord(map);
    }

    /**
     * 2.16.审批访客申请（fanke/vetting）
     * */
    @Override
    public Result FangkeVetting( UpdateVisitorRecordVo updateVisitorRecordVo) {
        return humanClientService.UpdateVisitorRecord(updateVisitorRecordVo);
    }

    /**
     * 2.15.待审批列表（fangke/getApprovalList）
     * */
    @Override
    public Result FangkeGetApprovalList(Map<String, Object> map) {
        map.put("approverId",map.get("pId"));
        map.put("page",0);
        map.put("size",0);
        map.remove("pId");
        return humanClientService.GetVisitorRecord(map);
    }

    /**
     * 2.17.访客详情(fangke/detail)
     * */
    @Override
    public Result Fangkedetail(Long comId, Long recodeId) {
        return humanClientService.DetailVisitorInfo(comId,recodeId);
    }

    /**
     * 2.18.审批负责人列表（fangke/approval）
     * */
    @Override
    public Result FangkeApproval(Long comId) {
        Map<String, Object> map = new HashMap<>();
        MapKey mapKey = new MapKey();
        map.put(mapKey.getKey_comId(),comId);
        map.put(mapKey.getKey_page(),0);
        map.put(mapKey.getKey_size(),0);
        return humanClientService.GetVisitorApprover(map);
    }

    /**
     * 2.19.获取审批区域列表(fangke/areas)
     * */
    @Override
    public Result FangkeAreas(Long comId, Long pId) {
        Long companyId = comId;
        return accessClientService.getAccessByUser(companyId,pId);
    }


}
